<!-- 我的工作 -->
<template>
	<view class="p-3">
		<view>
			<bg-title class="mb-3">
				<text class="font-2 font-bold">现任工作</text>
			</bg-title>
			<view class="bt-block px24py30 mb-3" v-if="current">
				<view class="flex justify-between mb-2">
					<view class="font-14">{{current.projectName}}</view>
					<view class="font-1 font-bold">{{current.workJobTypeName||getRole()}}</view>
				</view>
				<bg-desc label="开始时间" :value="current.startTime"></bg-desc>
			</view>
			<u-empty v-else></u-empty>
		</view>
		<view>
			<bg-title class="mb-3">
				<text class="font-2 font-bold">历史工作</text>
			</bg-title>
			<view v-if="history.length > 0 ">
				<view class="bt-block px24py30 mb-3" v-for="item,idx in history" :key="idx">
					<view class="flex justify-between mb-2">
						<view class="font-14">{{item.projectName}}</view>
						<view class="font-1 font-bold">{{item.workJobTypeName}}</view>
					</view>
					<bg-desc label="开始时间" :value="item.startTime"></bg-desc>
				</view>
			</view>
			<u-empty v-else></u-empty>
			
		</view>
	</view>
</template>

<script>
	import { currentWork, historyWork } from '../../../api/mine'
	export default {
		data() {
			return {
				params:{
					pageNum:1,
					pageSize:1000
				},
				current:{},
				history:[]
			}
		},
		mounted() {
			this.getData()
		},
		methods: {
			getData(){
				currentWork().then(res=>{
					this.current=res.data
					if(this.current&&!this.current.workJobTypeName){
						this.current.workJobTypeName=this.getRole()
					}
				})
				historyWork(this.params).then(res=>{
					this.history = res.data.rows
				})
			},
			getRole(){
				if(this.$auth.hasRole("team")){
					return "班组长"
				}
				if(this.$auth.hasRole("project")){
					return "项目管理员"
				}
			}
		}
	}
</script>

<style>

</style>
